#ifndef _RING_BUF_H_
#define _RING_BUF_H_

#define RING_BUF_SIZE   (2*4096)

typedef struct {
    WDFSPINLOCK lock;
    WDFMEMORY   wdfmem_obj;
    UCHAR       *p_buf;
    LONG        wr_idx;
    LONG        rd_idx;
    LONG        size;
} RING_BUF;

extern NTSTATUS rb_init(IN WDFDEVICE device);
extern size_t rb_write(RING_BUF *p_rb, UCHAR *buf, size_t len);
extern size_t rb_read(RING_BUF *p_rb, UCHAR *buf, size_t max_len);
extern size_t rb_getAvailableDataSize(RING_BUF *p_rb);
extern size_t rb_getFreeDataSize(RING_BUF *p_rb);
extern void rb_clear(RING_BUF *p_rb);

#endif